EIP (Ethereum Improvement Proposal): A standard procedure for proposing changes, updates, or improvements to the Ethereum network. These proposals outline new features or processes for Ethereum.
ERC (Ethereum Request for Comment): It defines standards and conventions for Ethereum applications, primarily smart contracts. ERC standards are the blueprint for how specific smart contract functions should be implemented and interacted with.
Each ERC-20 token implements a set of mandatory functions to ensure compatibility.
| Function | Description |
|---|---|
totalSupply() |
Returns the total supply of tokens. |
balanceOf(address account) |
Returns the token balance of a specific address. |
transfer(address to, uint256 amount) |
Transfers tokens from the caller’s address to another. |
transferFrom(address from, address to, uint256 amount) |
Transfers tokens from one address to another on behalf of an address that approved the sender. |
approve(address spender, uint256 amount) |
Allows a spender to withdraw tokens from the caller’s account multiple times, up to a specified amount. |
allowance(address owner, address spender) |
Returns the remaining number of tokens that the spender is allowed to spend on behalf of the owner. |
| Events | The ERC-20 standard requires the emission of certain events to reflect actions taken by the token. |
Transfer(address from, address to, uint256 amount) |
Event triggered when tokens are transferred. |
Approval(address owner, address spender, uint256 amount) |
Event triggered when the approve() function is called, notifying the network of the approval. |
totalSupply():
function totalSupply() public view returns (uint256);
balanceOf(address account):
uint256).function balanceOf(address account) public view returns (uint256);
transfer(address to, uint256 amount):
function transfer(address to, uint256 amount) public returns (bool);
transferFrom(address from, address to, uint256 amount):
function transferFrom(address from, address to, uint256 amount) public returns (bool);
approve(address spender, uint256 amount):
function approve(address spender, uint256 amount) public returns (bool);
allowance(address owner, address spender):
function allowance(address owner, address spender) public view returns (uint256);
Events (Transfer & Approval):
approve() is called, allowing applications to track approvals.ERC-721 includes many of the same functions as ERC-20 but with additional features for managing individual tokens, since each one is unique.
| Function | Description |
|---|---|
balanceOf(address owner) |
Returns the number of NFTs owned by a specific address. |
ownerOf(uint256 tokenId) |
Returns the owner of a particular token. |
transferFrom(address from, address to, uint256 tokenId) |
Transfers ownership of a specific NFT. |
approve(address to, uint256 tokenId) |
Approves another address to transfer a specific token on behalf of the owner. |
getApproved(uint256 tokenId) |
Returns the approved address for a specific token. |
setApprovalForAll(address operator, bool approved) |
Approves or removes an operator (typically for managing multiple tokens). |
isApprovedForAll(address owner, address operator) |
Checks if an operator is approved to manage all of the owner’s assets. |
| Events | Events help in tracking changes and interactions with the NFTs. |
Transfer(address from, address to, uint256 tokenId) |
Event triggered when an NFT is transferred. |
Approval(address owner, address approved, uint256 tokenId) |
Event triggered when an NFT’s approval is updated. |
balanceOf(address owner):
function balanceOf(address owner) public view returns (uint256);
ownerOf(uint256 tokenId):
function ownerOf(uint256 tokenId) public view returns (address);
transferFrom(address from, address to, uint256 tokenId):
function transferFrom(address from, address to, uint256 tokenId) public;
approve(address to, uint256 tokenId):
function approve(address to, uint256 tokenId) public;
getApproved(uint256 tokenId):
function getApproved(uint256 tokenId) public view returns (address);
setApprovalForAll(address operator, bool approved):
function setApprovalForAll(address operator, bool approved) public;
isApprovedForAll(address owner, address operator):
function isApprovedForAll(address owner, address operator) public view returns (bool);
Events (Transfer & Approval):
**: Emitted when a token’s approved operator is changed.
| Aspect | ERC-20 | ERC-721 |
|---|---|---|
| Type of Token | Fungible | Non-fungible |
| Uniqueness | Tokens are identical and interchangeable | Each token is unique and cannot be exchanged on a 1:1 basis |
| Use Cases | Cryptocurrencies, utility tokens | NFTs, digital art, collectibles |
| Divisibility | Can be fractional (e.g., 0.1 ETH) | Indivisible, must be transferred as whole tokens |
| Metadata | No unique metadata per token | Unique metadata for each token |
| Events | Transfer, Approval |
Transfer, Approval, ApprovalForAll |